home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / devglry / zoetek / source / shckclck.dir / 00094_Alarm Routines.ls < prev    next >
Encoding:
Text File  |  1996-04-11  |  2.3 KB  |  85 lines

  1. global mouseEnabled, mouseTimer, alarmval, alarmon, shockTime, tick, bignil, beeps, mouseVal, mouseCycle
  2.  
  3. on alarmInit
  4.   set mouseEnabled to 0
  5.   set mouseTimer to the timer
  6.   set alarmval to [#hour: 0, #minute: 0, #second: 0]
  7.   set alarmon to 0
  8. end
  9.  
  10. on alarm
  11.   set hour to the hour of alarmval
  12.   set twelveHrMode to the twelveHrMode of shockTime
  13.   if twelveHrMode then
  14.     set pm to hour > 11
  15.     set hour to 1 + ((hour - 1) mod 12)
  16.     if not hour then
  17.       set hour to 12
  18.     end if
  19.   end if
  20.   donum(1, bignil, the pad of shockTime, hour)
  21.   donum(4, bignil, 1, the minute of alarmval)
  22.   donum(7, bignil, 1, the second of alarmval)
  23.   ampm(twelveHrMode, pm, 1)
  24.   set tick to 1
  25.   time(0)
  26. end
  27.  
  28. on checkAlarm
  29.   if alarmon then
  30.     set hour to the hour of shockTime
  31.     if the twelveHrMode of shockTime then
  32.       set hour to (hour mod 12) + (12 * the pm of shockTime)
  33.     end if
  34.     if (hour = the hour of alarmval) and (the minute of shockTime = the minute of alarmval) and (the second of shockTime = the second of alarmval) then
  35.       set beeps to 15
  36.     end if
  37.   end if
  38. end
  39.  
  40. on checkMouse
  41.   if mouseEnabled and the mouseDown then
  42.     set enabled to rollOver(the clickOn)
  43.     if enabled and (the timer > (mouseTimer + 30 - (mouseCycle * 2))) then
  44.       set mouseCycle to mouseCycle + 1
  45.       do(the frameLabel & "inc")
  46.       updateStage()
  47.       set mouseTimer to the timer
  48.     end if
  49.   else
  50.     set mouseEnabled to 0
  51.     set enabled to 0
  52.   end if
  53.   return enabled
  54. end
  55.  
  56. on alarmInc
  57.   inc(alarmval, 24, 0)
  58.   set alarmval to the result
  59.   alarm()
  60. end
  61.  
  62. on inc orig, modval, docarry
  63.   set total to [#hour: 0, #minute: 0, #second: 0]
  64.   set sec to the second of orig + the second of mouseVal
  65.   set carry1 to docarry * ((sec > 59) - (sec < 0))
  66.   set the second of total to (sec + 60) mod 60
  67.   set min to the minute of orig + the minute of mouseVal + carry1
  68.   set carry2 to docarry * ((min > 59) - (min < 0))
  69.   set the minute of total to (min + 60) mod 60
  70.   set the hour of total to (the hour of orig + the hour of mouseVal + modval + carry2) mod modval
  71.   set tick to 1
  72.   return total
  73. end
  74.  
  75. on indicatealarm
  76.   if beeps then
  77.     set x to the number of cast "beepon"
  78.   else
  79.     set x to the number of cast "alarmoff" + alarmon
  80.   end if
  81.   set the castNum of sprite 18 to x
  82.   set the visible of sprite 18 to alarmon or beeps
  83.   updateStage()
  84. end
  85.